package hoyo.zqy.log.controller;

import hoyo.zqy.basic.util.AjaxResult;
import hoyo.zqy.basic.util.PageList;
import hoyo.zqy.log.annotation.LogAnnotation;
import hoyo.zqy.log.domain.LogDomain;
import hoyo.zqy.log.query.LogQuery;
import hoyo.zqy.log.service.ILogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/logs")
public class LogController {
    @Autowired
    private ILogService logService;

    @PostMapping("/list")
    public PageList<LogDomain> page(@RequestBody LogQuery query){
        return logService.queryPage(query);
    }

    @PatchMapping
    @LogAnnotation(module="日志",operater="日志批量删除")
    public AjaxResult batchRemoveByIds(@RequestBody Long[] ids){
        try {
            logService.deleBatch(ids);
            return new AjaxResult();
        } catch (Exception e) {
            e.printStackTrace();
            return new AjaxResult(false,"失败了,正在殴打程序猿中");
        }
    }

}
